<?php

namespace frontend\controllers;
use frontend\models\ApplyModel;
use frontend\models\JobModel;
use frontend\models\UserinfoModel;

class MemberController extends \yii\web\Controller
{    
     //user 模拟登陆
    public $user=1;
    public function actionIndex()
    {
        $this->redirect(['apply']);
    }
     //个人中心
    public function actionApply(){
      //模拟登陆
       $user_id = $this->user;
       $ApplyModel = ApplyModel::find()->where('apply_status=0 or apply_status=1 and user_id='.$user_id);
       $res = $ApplyModel->all();
       $arr = [];
       $data = [];
       foreach ($res as $key => $value) {

          $obj = JobModel::find($value->job_id);
          if ($value->apply_status==0) {
          
            $arr[$key]=$obj->one();
            $arr[$key]->job_num = $value->apply_addtime;

          }elseif($value->apply_status==1){
             $data[$key]=$obj->one();
             $data[$key]->job_num = $value->apply_addtime;
          }
      
       }
     
    	return $this->render('member_apply',['res'=>$res,'none'=>$arr,'success'=>$data]);
    }

    //已收藏的职位
    public function actionCollect()
    {
    	return $this->render('member_collect');
    }
  
    //账户设置
    
    public function actionInfo()
    {
    	return $this->render('member_info');
    }
    //简历
	  public function actionResume()
    {
      // echo $this->user;
       $UserinfoModel =  UserinfoModel::find()->where('user_id='.$this->user.' and status = 1 order by userinfo_id desc ' );
       $res = $UserinfoModel->one();

      // echo $UserinfoModel->createCommand()->getRawSql();die;
      return $this->render('member_resume',['res'=>$res]);
	  }
 


}
